class TokenObserver < ActiveRecord::Observer
  
  def after_create(token)
#    token.place.arcs.find(:all, :conditions => {:from_is_place => true}).each do |arc|
#      if !arc.kind_of?(InhibitorArc) && !arc.kind_of?(ResetArc) 
#        arc.transition.modtokens.create!(:token => token)
#        arc.transition.save!
#      end
#    end
    true
  end

  def after_update(token)
#    token.place.arcs.find(:all, :conditions => {:from_is_place => true}).each do |arc|
#      begin
#        token.combinations.destroy_all
#        if (arc.transition.modtokens.select{|modtoken| modtoken.token == token}.size == 0)
#          arc.transition.modtokens.create!(:token => token)
#          arc.transition.save!
#        end
#      rescue Exception => ex
#        raise "Updating modtokens for transition #{arc.transition.id} failed."	
#      end
#    end
    true
  end

  def before_destroy(token)
    #cleanup(token)
    true
  end
end
